package com.pingtai.financial.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.pingtai.dao.BaseDao;
import com.pingtai.indent.entity.UserBaseIndentType;
import com.pingtai.user.entity.UserPay;

public class FinancialDao extends BaseDao {

	public List getBaseIndentTypeFromUserPayByIndentId(Integer indentId){
		Session session = getSession();
		Query query = session.createQuery("from UserPay where userIndent.id=:indentId");
		query.setParameter("indentId", indentId);
		List list = query.list();
		
		if(list!=null&&list.size()>0){
			List arrayList = new ArrayList();
			UserPay userPay = (UserPay) list.get(0);
			UserBaseIndentType b = userPay.getUserBaseIndent();
			UserPay userPay2 = (UserPay) list.get(list.size()-1);
			arrayList.add(b);
			if(userPay2.getType2()!=null&&userPay2.getType2()==4){
				arrayList.add(false);
			}else{
				arrayList.add(true);
			}
			return arrayList;
		}
		return null;
	}
}
